{% extends 'base.html' %}

{% block title %}{{ title }} - 教务信息管理系统{% endblock %}

{% block content %}
<div class="row">
    <div class="col-12">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h2>
                <i class="fas fa-user-times me-2 text-danger"></i>
                {{ title }}
            </h2>
            <a href="{% url 'accounts:user_list' %}" class="btn btn-secondary">
                <i class="fas fa-arrow-left me-1"></i>返回用户列表
            </a>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-lg-6 col-md-8 mx-auto">
        <div class="card shadow border-danger">
            <div class="card-header bg-danger text-white">
                <h5 class="card-title mb-0">
                    <i class="fas fa-exclamation-triangle me-2"></i>
                    确认删除用户
                </h5>
            </div>
            <div class="card-body">
                <div class="alert alert-warning">
                    <i class="fas fa-exclamation-triangle me-2"></i>
                    <strong>警告：</strong>此操作不可撤销！删除用户将同时删除其所有相关数据。
                </div>
                
                <div class="user-info bg-light p-3 rounded mb-4">
                    <h6 class="mb-3">
                        <i class="fas fa-user me-2"></i>
                        即将删除的用户信息：
                    </h6>
                    
                    <div class="row">
                        <div class="col-sm-4"><strong>用户名：</strong></div>
                        <div class="col-sm-8">{{ user_to_delete.username }}</div>
                    </div>
                    
                    <div class="row mt-2">
                        <div class="col-sm-4"><strong>姓名：</strong></div>
                        <div class="col-sm-8">{{ user_to_delete.first_name|default:"未设置" }}</div>
                    </div>
                    
                    <div class="row mt-2">
                        <div class="col-sm-4"><strong>邮箱：</strong></div>
                        <div class="col-sm-8">{{ user_to_delete.email|default:"未设置" }}</div>
                    </div>
                    
                    <div class="row mt-2">
                        <div class="col-sm-4"><strong>角色：</strong></div>
                        <div class="col-sm-8">
                            {% if user_to_delete.userprofile %}
                                <span class="badge bg-{% if user_to_delete.userprofile.is_admin %}primary{% else %}info{% endif %}">
                                    {{ user_to_delete.userprofile.get_role_display }}
                                </span>
                            {% else %}
                                <span class="text-muted">未设置</span>
                            {% endif %}
                        </div>
                    </div>
                    
                    {% if user_to_delete.userprofile.college_name %}
                    <div class="row mt-2">
                        <div class="col-sm-4"><strong>学院：</strong></div>
                        <div class="col-sm-8">{{ user_to_delete.userprofile.college_name }}</div>
                    </div>
                    {% endif %}
                    
                    <div class="row mt-2">
                        <div class="col-sm-4"><strong>注册时间：</strong></div>
                        <div class="col-sm-8">{{ user_to_delete.date_joined|date:"Y-m-d H:i" }}</div>
                    </div>
                    
                    <div class="row mt-2">
                        <div class="col-sm-4"><strong>状态：</strong></div>
                        <div class="col-sm-8">
                            {% if user_to_delete.is_active %}
                                <span class="badge bg-success">激活</span>
                            {% else %}
                                <span class="badge bg-secondary">禁用</span>
                            {% endif %}
                        </div>
                    </div>
                </div>
                
                <div class="alert alert-info">
                    <i class="fas fa-info-circle me-2"></i>
                    <strong>影响范围：</strong>
                    <ul class="mb-0 mt-2">
                        <li>用户账号将被永久删除</li>
                        <li>用户创建的子项目记录将保留，但创建者信息将显示为"已删除用户"</li>
                        <li>用户的个人信息和权限设置将被删除</li>
                    </ul>
                </div>
                
                <form method="post" class="mt-4">
                    {% csrf_token %}
                    <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                        <a href="{% url 'accounts:user_list' %}" class="btn btn-secondary me-md-2">
                            <i class="fas fa-times me-1"></i>取消
                        </a>
                        <button type="submit" class="btn btn-danger">
                            <i class="fas fa-trash me-1"></i>确认删除
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}